Swipe Actions
In the Scripting app, you can attach swipe actions to views used as rows in a <List> (such as <HStack>) to support contextual interactions like deleting, editing, marking favorites, etc.
To improve clarity and ease of use in TypeScript, the SwiftUI swipeActions modifier is split into two separate modifiers:
leadingSwipeActions: For swipe gestures from left to right.trailingSwipeActions: For swipe gestures from right to left.
leadingSwipeActions
Adds swipe actions to the leading (left) edge of a list row.
Type
Description
actions: An array of<Button>elements that will appear when the user swipes right on the row.allowsFullSwipe: Iftrue(default), a full swipe will automatically invoke the first action in the list.
trailingSwipeActions
Adds swipe actions to the trailing (right) edge of a list row.
Type
Description
actions: An array of<Button>elements that appear when the user swipes left on the row.allowsFullSwipe: Iftrue(default), a full swipe will automatically trigger the first action.
Example Usage
You can also add leading actions:
Button Roles and Styling
Each swipe action must be a <Button> component. You can customize buttons with:
title: Text label for the button.action: The function to execute when tapped.role(optional):"destructive"for delete-like actions.tint(optional): Use system color names like"accentColor"or any custom color string.
Notes
- You can use both
leadingSwipeActionsandtrailingSwipeActionson the same row. - Only views used within a scrollable list (like
<List>) support swipe actions. - If
allowsFullSwipeis disabled, the user must tap the button rather than relying on a full swipe gesture.
